<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript">
$(document).ready(function() { 
        $("#usersTable").tablesorter({ 
        // pass the headers argument and assing a object 
        headers: { 
            // assign the first column (we start counting zero) 
            0: { 
                // disable it by setting the property sorter to false 
                sorter: false
            }
        }
    }); 
    } 
);

function checkSetAll(value, name) {
	var objs = document.getElementsByName('selectedUsers');
	for (var i = 0; i < objs.length; i++) {
		objs[i].checked = value;
	}
}
</script> 
<div>

	<div class="title"><s:text name="user.list.title"></s:text></div>

	<div class="container">
		<form action="../users/User.action" method="post">
			<s:hidden name="mode" value="L"></s:hidden>
			<s:text name="gallery.name" />
			<input type="text" name="query" value="<s:property value="query"/>"/>
			<button class="action" type="submit" name="search"><s:text name="user.list.search" /></button>			
			<s:if test="%{query != ''}" >
				<button class="action" type="submit" name="search" 
						onclick="javascript: return submitClear(this.form);">
					<s:text name="user.list.clear" />
				</button>			
			</s:if>
		</form>
	</div>

	<s:form action="/users/User.action" method="POST">
		<s:hidden name="mode" value="D"></s:hidden>
		<table id="usersTable" class="tablesorter" > 
			<thead> 
				<tr> 
				    <th class="checkboxes">&nbsp;</th> 
				    <th><s:text name="user.list.userId"></s:text></th> 
				    <th><s:text name="user.list.userName"></s:text></th> 
				    <th><s:text name="user.list.admin"></s:text></th> 
				</tr> 
			</thead>
			<tbody>
				<s:iterator id="user" value="users">
				<tr>
					<td><s:if test="%{!#user.userId.equals(#session.session_user.userId)}" >
							<input type="checkbox" name="selectedUsers" 
								value="<s:property id="user" value="userId"/>">
						</s:if>
						<s:else></s:else>
						</td>
					<td>
						<a href="User.action?mode=E&userId=<s:property id="user" value="userId"/>"> 
							<s:property id="user" value="userId" default=" -none- "/> 
						</a>
					</td>
					<td>
						<s:property id="user" value="userName" default=" - "/>
					</td>
					<td>
						<s:if test="%{#user.admin}" >
							<s:text name="general.yes" />
						</s:if>
						<s:else>
							<s:text name="general.no" />
						</s:else>
					</td>
				</tr>
			</s:iterator>
			</tbody>
		</table>
		<div class="container">
			<button class="action" onclick="javascript: checkSetAll(true, 'selectedUsers'); return false;"><s:text name="user.list.selectAll"/></button>
			<button class="action" onclick="javascript: checkSetAll(false, 'selectedUsers'); return false;"><s:text name="user.list.deselectAll"/></button>
			<button class="action" type="submit"><s:text name="user.list.delete"/></button>
			<a class="action" href="../users/User.action?mode=R"><s:text name="user.list.add"/></a>
		</div>
	</s:form>
</div>